<?php

namespace app\controller\bossManager;

use app\validate\PageValidate;
use app\validate\ToolkitUserValidate;
use app\service\ToolkitUserService;

class ToolkitUserController extends WebBossController{
    public function initValidate(){        
        $this->validate = new ToolkitUserValidate();
    }

    public function list_action(){  
        $input = $this->check();        
        $page = $this->check('pageInfo',null,(new PageValidate()));        
        $data = ToolkitUserService::getListInfo($input,$page);
        if($data && count($data) > 0){
            foreach($data as &$item){
                unset($item['salt']);
                unset($item['pass']);
            }
        }
        $total = ToolkitUserService::getListCountInfo($input);
        return self::ok(self::formatPageData($page,$total,$data));    
    }

    public function set_action(){  
        $input = $this->check();
        $res = ToolkitUserService::edit($input); 
        return self::ok($res);
    }

 
    // public function del_action(){ 
    //     $input = $this->check();
    //     $res = ToolkitUserService::delById($input['id']); 
    //     return self::ok($res);
    // }

    // public function simple_all_action(){
    //     //TODO change code here
    //     $data = ToolkitUserService::getNativeAll([],['id','name']);
    //     return self::ok($data); 
    // }
}